function t(t, e, o) {
    return e in t ? Object.defineProperty(t, e, {
        value: o,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = o, t;
}

var e = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("./we-cropper/we-cropper.js"));

Component({
    properties: {
        src: {
            type: String,
            value: "",
            observer: function(t, e) {
                t && (this.wecropper.pushOrign(t), this.show(!0));
            }
        },
        height: {
            type: Number,
            observer: function(t, e) {
                this.setData({
                    height: t
                });
            }
        }
    },
    data: {
        show: !1,
        isValid: !1,
        cropperOpt: {
            id: "cropper",
            width: 0,
            height: 0,
            scale: 2.5,
            zoom: 8,
            cut: {
                x: 0,
                y: 0,
                width: 0,
                height: 0
            }
        }
    },
    ready: function(o) {
        var r, i = this.data.height, c = wx.getSystemInfoSync(), n = c.windowWidth, h = c.windowHeight, s = Math.floor(.96 * c.windowWidth), p = Math.floor(i / 2) || s, a = Math.floor(100 / 750 * c.windowWidth);
        this.setData((r = {}, t(r, "cropperOpt.width", n), t(r, "cropperOpt.height", h - a), 
        t(r, "cropperOpt.cut.x", (n - s) / 2), t(r, "cropperOpt.cut.y", (h - p - a) / 2), 
        t(r, "cropperOpt.cut.width", s), t(r, "cropperOpt.cut.height", Math.floor(i / 2) || p), 
        r), function() {
            var t = this, o = this.data.cropperOpt;
            this.wecropper = new e.default(o, this).on("ready", function(e) {
                console.log("wecropper is ready for work!"), t.setData({
                    isValid: !0
                });
            });
        });
    },
    methods: {
        show: function(t) {
            this.setData({
                show: t
            });
        },
        touchStart: function(t) {
            this.wecropper.touchStart(t);
        },
        touchMove: function(t) {
            this.wecropper.touchMove(t);
        },
        touchEnd: function(t) {
            this.wecropper.touchEnd(t);
        },
        cancel: function(t) {
            this.setData({
                show: !1
            });
        },
        canvasError: function(t) {
            console.log("canvas error: " + t.detail.errMsg), this.show(!1);
        },
        sure: function(t) {
            var e = this;
            this.data.isValid && this.wecropper.getCropperImage({
                quality: 10
            }, function(t) {
                t ? (e.triggerEvent("crop", {
                    src: t
                }), e.show(!1)) : wx.showModal({
                    title: "裁剪",
                    content: "裁剪失败，请稍后重试",
                    success: function(t) {
                        t.confirm;
                        t.cancel && e.show(!1);
                    }
                });
            });
        }
    }
});